home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 337 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  60 lines

  1. Path: fido.asd.sgi.com!austern
  2. From: jarausch@igpm.rwth-aachen.de (Helmut Jarausch)
  3. Newsgroups: comp.std.c++
  4. Subject: Binding a temperary to a non const ref - status of the rules?
  5. Date: 08 Feb 1996 10:11:01 PST
  6. Organization: RWTH Aachen (Inst. f. Geometrie & Prakt. Mathematik)
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4fd0t6$8n5@news.rwth-aachen.de>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 8 Feb 1996 14:21:26 GMT
  11. X-Newsreader: xrn 7.00 (Motif)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMRo8zUy4NqrwXLNJAQFT5wH/Rve1Tbo9DeTObDFRHcuW6N/KGPKYUGOz
  14.     N8sy3dlbyS6OdQ5hFoPH3qq1BtmMdTir+ShYyujwvLT0gc/RP2UBzw==
  15.     =CxV4
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. Please comment on the following ( I know there is a connection to the
  19. auto_ptr discussion, but I am not quite sure about this).
  20. Thank you very much,
  21. Helmut Jarausch.
  22.  
  23. ========================
  24.  
  25. Assume
  26.  
  27. class  Vector { ... }
  28.  
  29. class Vector_R : public Vector
  30. { // a smart reference to a Vector using reference counts,
  31.   freeing temp. storage immediately after use
  32.   ...
  33. }
  34.  
  35. class Matrix
  36. {  // Data stored columnwise
  37.    ...
  38.    
  39.    const Vector_R operator[]( int k ) const;  // return k-th column vector
  40.          Vector_R operator[]( int k );        // return k-th column vector
  41.    ...
  42. }
  43.  
  44. ostream& operator<<( ostream&, const Vector&);
  45. istream& operator>>( istream&, Vector& );
  46.  
  47.       Matrix  V;
  48. const Matrix  K;
  49.  
  50.  
  51. Now I would like the following behaviour (is this true (or will it be) ? )
  52.  
  53. cout << V[1] << K[1];   // should be OK
  54. cout >> V[1];           // should be OK  (even no warning)
  55. cout >> K[1];           // should be an ERROR - not only a warning
  56. ---
  57. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  58.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  59.   in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  60.